﻿using System;
using com.yoozoo.gta.Extension.UGUI.ScreenOrientationEx;
using UnityEngine;

namespace com.yoozoo.gta.Extension.UGUI.ScreenOrientation.Adapter
{
    
    [Serializable]
    public class BoxCollider2DAdapterConfig
    {
        public bool enable = true;
        public bool isTrigger;
        public Vector2 size;
        public Vector2 offset;
        
        //重写Equals方法
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }

            BoxCollider2DAdapterConfig other = (BoxCollider2DAdapterConfig)obj;
            // Compare enable properties
            if (enable != other.enable)
            {
                return false;
            }
            // Compare isTrigger properties
            if (isTrigger != other.isTrigger)
            {
                return false;
            }
            // Compare size properties
            if (size != other.size)
            {
                return false;
            }
            // Compare offset properties
            if (offset != other.offset)
            {
                return false;
            }

            return true;
        }
        
        //重写GetHashCode方法
        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * 23 + enable.GetHashCode();
            hash = hash * 23 + isTrigger.GetHashCode();
            hash = hash * 23 + size.GetHashCode();
            hash = hash * 23 + offset.GetHashCode();
            return hash;
        }
     
    }
    public class BoxCollider2DAdapter: AdaptBase<BoxCollider2DAdapterConfig, BoxCollider2D>
    {
        protected override void CopyProperty(BoxCollider2DAdapterConfig config) {
            base.CopyProperty(config);
            config.enable = mComponent.enabled;
            config.isTrigger = mComponent.isTrigger;
            config.size = mComponent.size;
            config.offset = mComponent.offset;
        }

        protected override void ApplyConfig(BoxCollider2DAdapterConfig config) {
            base.ApplyConfig(config);
            mComponent.enabled = config.enable;
            mComponent.isTrigger = config.isTrigger;
            mComponent.size = config.size;
            mComponent.offset = config.offset;
        }
    }

   
}